/*
 * Created on Sep 12, 2004
 */
package org.vectrics.recruiter.struts;

import java.util.Collection;
import java.util.Iterator;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.ecs.html.Option;
import org.vectrics.common.db.DataUtils;
import org.vectrics.common.html.Combo;
import org.vectrics.provider.CoreServiceLocator;
import org.vectrics.recruiter.RecruitServiceLocator;
import org.vectrics.recruiter.user.Resume;
import org.vectrics.struts.VectricsComboTag;
import org.vectrics.user.Person;

/**
 * @author mmoore
 */
public class ResumeComboTag extends VectricsComboTag {

	private static final long serialVersionUID = 239117956090927821L;

	private transient final Log log = LogFactory.getLog(this.getClass());
	private String personId = null;

	/*
	 * 
	 */
	public void makeOptions(Combo select) {
		log.debug("doStartTag() called");
		Person person = CoreServiceLocator.getPersonService().findPersonById(new Long(personId));
		Collection resumes = RecruitServiceLocator.getRecruitUserService().findCandidateInfo(person).getResumes(); 
    	resumes = DataUtils.removeVoided(resumes);
    	
		Iterator iter = resumes.iterator();
		while (iter.hasNext()) {
			Resume resume = (Resume)iter.next();
			Option option = new Option();
			option.setValue(resume.getId().toString());
			option.addElement(resume.getName());
			select.addElement(option);
		}
	}

	
	/**
	 * @return Returns the personId.
	 */
	public String getPersonId() {
		return personId;
	}
	/**
	 * @param personId The personId to set.
	 */
	public void setPersonId(String personId) {
		this.personId = personId;
	}
}
